package com.springbootbase.springbootproject.controller;


import com.springbootbase.springbootproject.pojo.Evaluation;
import com.springbootbase.springbootproject.pojo.Result;
import com.springbootbase.springbootproject.service.evaluationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/evaluation")
public class evaluationController {
    @Autowired
    private evaluationService evaluationService;

    @PostMapping("/addComment")
    public Result addComment(@RequestBody @Validated Evaluation evaluation){
        evaluationService.addComment(evaluation);
        return Result.success();
    }


    @GetMapping("/getComment")
    public Result<ArrayList> getComment(String username){
      ArrayList<Evaluation> evaluationArrayList =  evaluationService.getComment(username);
        return Result.success(evaluationArrayList);
    }
}
